package com.hut.oa.model.bean;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.springframework.format.annotation.DateTimeFormat;
@Entity
@Table(name="discuss_vote")
public class DiscussVote {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="v_id")
	private Long id;//主键id
	
	@Column(name="v_style",nullable=false)
	private Integer style;//投票类型
	
	@Temporal(TemporalType.DATE)
	@DateTimeFormat(pattern="yyyy-MM-dd")
	@Column(name="v_end_time",nullable=false)
	private Date vendTime;//投票截止时间时间
	
	@OneToMany(cascade=CascadeType.ALL,mappedBy="vote",orphanRemoval = true)
	List<DiscussVoteSelectContent> voteContents;
	
	@JoinColumn(name="da_id")
	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	private DiscussArea discuss;//帖子id
	

	public DiscussVote() {}
	
	public List<DiscussVoteSelectContent> getVoteContents() {
		return voteContents;
	}

	public void setVoteContents(List<DiscussVoteSelectContent> voteContents) {
		this.voteContents = voteContents;
	}



	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getStyle() {
		return style;
	}

	public Date getVendTime() {
		return vendTime;
	}

	public void setVendTime(Date vendTime) {
		this.vendTime = vendTime;
	}

	public void setStyle(Integer style) {
		this.style = style;
	}

	public DiscussArea getDiscuss() {
		return discuss;
	}

	public void setDiscuss(DiscussArea discuss) {
		this.discuss = discuss;
	}

	@Override
	public String toString() {
		return "Vote [id=" + id + ", style=" + style + ", vendTime=" + vendTime + ", discuss=" + discuss
				+ "]";
	}
	

}
